import { myRequest } from '../../api/myRequest'
import { actionsMap } from '../../api/url'
import lodash from 'lodash'

const $RC = 'Hier'
const $action = actionsMap[$RC]

export default {
    HierInstanceQueryWithLink(filter) {
      return myRequest($RC, [{ action: $action.INSTANCE_QUERY_WITH_LINK, ...filter }])
    },
    HierInstanceSaveHier(record) {
      return myRequest($RC, [{ 
        action: $action.INSTANCE_SAVE_HIER_WITHOUT_MODEL, 
        data: lodash.isArray(record) ? record : [record] 
      }])
    },
    HierInstanceDeleteHier(ids) {
      return myRequest($RC, [{ action: $action.INSTANCE_DELETE_HIER_BY_ID_LIST, ids }])
    },
    HierInstanceQueryByPage(param) {
      return myRequest($RC, [{ action: $action.INSTANCE_QUERY_BY_PAGE, ...param }])
    },
    HierInstanceQueryById(id) {
        return myRequest($RC, [{ action: $action.INSTANCE_QUERY_BY_ID, id}])
    },
    HierInstanceQueryByPageWithContainerId(param) {
      return myRequest($RC, [{ action: $action.INSTANCE_QUERY_BY_PAGE_WITH_CONTAINERID, ...param }])
    },
}